package org.bhf.json;

import java.io.Serializable;
import java.util.List;

/**
 * A single conversion error during JSON parsing and state overlay.
 */
public class ConversionError implements Serializable
{
    private static final long serialVersionUID = 1L;

    final private String    path;
    final private String    value;
    final private Class     type;

    /**
     *
     * @param context Parsing context (property path)
     * @param value Value that failed conversion
     * @param type Target type for the conversion.
     * @exclude
     */
    public ConversionError( final List<String> context, final String value, final Class type )
    {
        this.path   = Util.stackToPath( context );
        this.value  = value;
        this.type   = type;
    }

    /**
     * The property path to the failed conversion.
     * @return The property path to the failed conversion.
     */
    public String getPath()
    {
        return path;
    }

    /**
     * The value that failed conversion.
     * @return The value that failed conversion.
     */
    public String getValue()
    {
        return value;
    }

    /**
     * The target type of the conversion. May be <code>null</code>, which indicates that the target property
     * did not exist.
     * @return The target type of the conversion.
     */
    public Class getType()
    {
        return type;
    }
}
